import request from "@/utils/request";

// 发布博客
export function publishBlog(data) {
    return request({
        url: "/blog/publish",
        method: "post",
        data,
    });
}

// 保存草稿
export function saveDraft(data) {
    return request({
        url: "/blog/draft",
        method: "post",
        data,
    });
}

// 获取博客详情
export function getBlogDetail(id) {
    return request({
        url: `/blog/all/${id}`,
        method: "get",
    });
}

//博客列表
export function getBlogs(params) {
    return request({
        url: "/blog/all/",
        method: "get",
        params,
    });
}

export function getHighAgreeBlogs() {
    return request({
        url: "/blog/all/highAgree",
        method: "get",
    });
}

// 获取相关博客
export function getRelatedBlogs(id) {
    return request({
        url: `/blog/all/related`,
        method: "get",
        params: { id },
    });
}

// 点赞博客
export function agreeBlog(id) {
    return request({
        url: `/blog/agree`,
        method: "get",
        params: { id },
    });
}

// 关注作者
export function followAuthor(authorId) {
    return request({
        url: `/user/follow`,
        method: "get",
        params: { authorId },
    });
}

// 发表评论
export function createComment(blogId, content) {
    return request({
        url: `/blog/comments`,
        method: "post",
        data: { blogId, content },
    });
}

export function collectBlog(id) {
    return request({
        url: "/blog/collect",
        method: "post",
        params: { id },
    });
}

export function cancelCollectBlog(id) {
    return request({
        url: "/blog/cancelCollect",
        method: "post",
        params: { id },
    });
}
